
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import config from './config.js'
Vue.config.productionTip = false

App.mpType = 'app'

// 统一提示
function msg(title = "", duration = 1000, icon = 'none', mask = false) {
	uni.showToast({
		title: title,
		duration: duration,
		icon: icon ,// none success loading
		mask:mask
	});
}

// 异步请求数据
const request = function(path, method, data, failCallback, completeCallback){
	uni.showLoading({
		mask: true
	})
	return new Promise((resolve,reject) => {
		uni.request({
			url: config.baseUrl + path,
			data: data,
			method: method,
			timeout: 2000,
			header: {
				'Content-Type': 'application/json; charset=UTF-8'
			}
		}).then(data => {
            let [err, res] = data;
			uni.hideLoading();
            resolve(res);
        }).catch(error => {
			uni.hideLoading();
            reject(error);
        })
	})
}
Vue.prototype.$msg = msg;
Vue.prototype.$request = request;
const app = new Vue({
    ...App
})
app.$mount()
// #endif

